

#import "BIDChartPageViewController.h"
#import "PieChartViewController.h"
#import "MonthlyLineChartViewController.h"
#import "YearlyLineChartViewController.h"
//#import "BIDAppDelegate.h"

@interface BIDChartPageViewController ()

@end

@implementation BIDChartPageViewController{
    NSInteger current;
}

- (void)viewWillAppear:(BOOL)animated{
    //[super viewWillAppear:animated];
	// Do any additional setup after loading the view.
    self.dataSource = self;
    self.delegate = self;
    //   
    PieChartViewController *devOfTheMonth  = [[PieChartViewController alloc] init];
    //
    MonthlyLineChartViewController *monthly = [[MonthlyLineChartViewController alloc] init];
    YearlyLineChartViewController *yearly = [[YearlyLineChartViewController alloc] init];
    self.controllers = [[NSMutableArray alloc] init];
    [self.controllers addObject:devOfTheMonth];
    [self.controllers addObject:monthly];
    [self.controllers addObject:yearly];
    NSArray *controller = [NSArray arrayWithObject:[self.controllers objectAtIndex:0]];
    [self setViewControllers:controller direction:UIPageViewControllerNavigationDirectionForward animated:NO completion:nil];
    current = 0;
}

#pragma mark - Page View Controller Data Source
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerBeforeViewController:(UIViewController *)viewController{
    if (current == 0){
        return nil;
    }else{
        current = current - 1;
    }
    //NSLog(@"current is: %d", current);
    return [self.controllers objectAtIndex:current];
}
- (UIViewController *)pageViewController:(UIPageViewController *)pageViewController viewControllerAfterViewController:(UIViewController *)viewController{
    if (current == [self.controllers count] - 1){
        return nil;
    }else{
        current = current + 1;
    }
    //NSLog(@"current is: %d", current);
    //NSLog(@"recognizers count is: %d", [pageViewController.gestureRecognizers count]);
    return [self.controllers objectAtIndex:current];
}
- (NSInteger)presentationCountForPageViewController:(UIPageViewController *)pageViewController{
    return [self.controllers count];
}
- (NSInteger)presentationIndexForPageViewController:(UIPageViewController *)pageViewController{
    return current;
}
#pragma mark - Page View Controller Delegate
@end
